package com.example.demo.scheduledtask;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.demo.mapper.PoMpsinfoMapper;
import com.example.demo.vo.PoMpsinfoVo;
import com.example.demo.vo.PurchaseSupplyMaterialVo;
import com.example.demo.vo.PurchaseSupplyVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.xml.soap.*;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 */
@Component
@Slf4j
@DS("wms")
public class PurchaseSupplyBackfillScheduledTask {

    @Autowired
    PoMpsinfoMapper poMpsinfoMapper;

    /**
     * 定时同步采购单明细到WMS数据库
     */
//    @Scheduled(cron = "0 0/10 * * * ?")
//    @Async(value = "taskExecutor")
    public void syncProcurementDetails(){
        poMpsinfoMapper.syncProcurementDetails();
    }

    /**
     * 定时同步采购收货单明细到WMS数据库---检验单 zs 20240409修改为及时获取
     */
//    @Scheduled(cron = "0/30 * * * * ?")
//    @Async(value = "taskExecutor")
    public void syncPurchaseReceiptDetails(){
        poMpsinfoMapper.syncPurchaseReceiptDetails();
    }

    /**
     * 收料回写erp正常状态有问题调整
     */
    @Scheduled(cron = "0/5 * * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpNotOkExecSl(){
        poMpsinfoMapper.wmsErpNotOkExecSl();
    }

    /**
     * 上架回写erp正常状态有问题调整
     */
    @Scheduled(cron = "0/6 * * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpNotOkExecSj(){
        poMpsinfoMapper.wmsErpNotOkExecSj();
    }

    /**
     * 生产发料回写erp正常状态有问题调整
     */
//    @Scheduled(cron = "0/7 * * * * ?")
//    @Async(value = "taskExecutor")
//    public void wmsErpNotOkExecOutScfl(){
//        poMpsinfoMapper.wmsErpNotOkExecOutScfl();
//    }

    /**
     * 数据反写中超过两个小时重新过账-10分钟执行一次
     */
    @Scheduled(cron = "0/10 * * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsAnewCallBack(){
        poMpsinfoMapper.wmsAnewCallBack();
    }
}
